package com.example.ruihuada.base

import android.content.Context
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.annotation.Nullable
import androidx.fragment.app.Fragment
import com.example.ruihuada.R


abstract class BaseFragment : Fragment() {
    var emptyWarpLayout: FrameLayout? = null
    var mContext: Context? = null


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mContext = activity
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val rootView = inflater.inflate(R.layout.fragment_base, container, false)
        rootView.findViewById<FrameLayout>(R.id.contentPanel)
            .addView(layoutInflater.inflate(getLayoutId(), null))
        return rootView
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        emptyWarpLayout = view.findViewById(R.id.contentPanel)
        initView()
        startLiveBusObserve()
    }

    override fun onDestroy() {
        super.onDestroy()
    }

    open fun setData(@Nullable data: Any?) {

    }


    abstract fun getLayoutId(): Int
    protected abstract fun initView()


    protected open fun onPageClick() {}
    protected open fun startLiveBusObserve() {}

}